<#include "/macro/base.ftl" />
<link rel="stylesheet" href="ztree/css/demo.css" type="text/css">
<link rel="stylesheet" href="ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="ztree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="ztree/js/jquery.ztree.excheck.js"></script>
<script type="text/javascript">
	var zTree;
	var tree_node_json =[];
	var setting = {
		check: {
			enable: true,
			chkStyle : "checkbox"
		},
		data: {
			simpleData: {
				enable:true,
				idKey: "id",
				pIdKey: "pid",
				rootPId: -1
			}
		},
		callback: {
			onCheck: function(event, treeId, treeNode) {
				var treeObj = $.fn.zTree.getZTreeObj("tree");
				var nodes=treeObj.getCheckedNodes(true);
           	    var obj ;
           	    for(var i=0;i<nodes.length;i++){
           	    	obj = new Object();
           	    	obj.id = nodes[i].id;
           	    	obj.name = nodes[i].name;
           	    	tTree_node_json.push(obj);
		        }
           	    $("#listPermission").val(JSON.stringify(tTree_node_json));
			},
			beforeCheck : function(event, treeId, treeNode) {
				tTree_node_json = [];
			}
		}
	};
	$(document).ready(function(){
		var t = $("#tree");
		t = $.fn.zTree.init(t, setting, ${tree});
		zTree = $.fn.zTree.getZTreeObj("tree");
		zTree.expandAll(false);
	});
</script>



<div class="pageContent">
	<form method="post" action="${base}/sys/sysRole/saveAuthorization" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<div class="pageFormContent" layoutH="58">
				
			<div style="float: left;width: 49%;height: 93%;">
				<input name="id" value="${(bean.id?c)!}" type="hidden"/>
				<input id="listPermission" name="listPermission" value="" type="hidden"/>
				
				<p>
					<label>角色名称：</label>
					<input name="role"  class="required" type="text" size="20" value="${(bean.role)!}" placeholder="请输入角色名称"/>
				</p>
				<p>
					<label>角色描述：</label>
					<input name="description"  class="required" type="text" size="20" value="${ (bean.description)!}" placeholder="请输入角色描述"/>
				</p>
				
			</div>	
			<div style="float: right;width: 49%;height: 93%;">
			   <ul id="tree" class="ztree"></ul>
			</div>
			
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
			</ul>
		</div>
	</form>
</div>
